package se.webbzon.boltzmann.player;

public class PlayerEnergy {
	
	// The maximal top energy of a player
	private static final int topEnergy = 100;
	
	// The current energy of the player
	private int energy;
	
	// The maximal energy of the player
	private int maxEnergy;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a a new player energy instance with 0 energy and 0
	 * maximal energy. **/
	public PlayerEnergy() {
		this(0,0);
	}
	
	/** Creates a a new player energy instance with a given energy and
	 * maximal energy. **/
	public PlayerEnergy(int maxEnergy, int energy) {
		this.maxEnergy = (maxEnergy > topEnergy) ? topEnergy : maxEnergy;
		this.energy = (energy > this.maxEnergy) ? this.maxEnergy : energy;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the current energy of the player. **/
	public int getEnergy() {
		return energy;
	}

	/** Sets the current energy of the player. **/
	public void setEnergy(int energy) {
		this.energy = (energy > maxEnergy) ? maxEnergy : energy;
	}

	/** Returns the maximal energy of the player. **/
	public int getMaxEnergy() {
		return maxEnergy;
	}

	/** Sets the maximal energy of the player. **/
	public void setMaxEnergy(int maxEnergy) {
		this.maxEnergy = (maxEnergy > topEnergy) ? topEnergy : maxEnergy;
	}

}
